package Day5ExerciseAssignment;
import java.awt.GridLayout;
import java.awt.event.*;

import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;

import javax.swing.WindowConstants;
import javax.swing.SwingUtilities;


/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class NewJFrame extends javax.swing.JFrame {
	private JLabel lblProvince;
	private JTextField txtPostal;
	private JTextField txtProvince;
	private JTextField txtCity;
	private JTextField txtAddress;
	private JTextField txtLastName;
	private JTextField txtFirstName;
	private JButton btnCancel;
	private JButton btnSave;
	private JLabel lblCity;
	private JLabel lblPostal;
	private JLabel lblAddress;
	private JLabel lblLastName;
	private JLabel lblFirstName;
	private static NewJFrame inst;

	/**
	* Auto-generated main method to display this JFrame
	*/
	public static void main(String[] args) {
		SwingUtilities.invokeLater(new Runnable() {
			public void run() {
				inst = new NewJFrame();
				inst.setLocationRelativeTo(null);
				inst.setVisible(true);
			}
		});
	}
	
	public NewJFrame() {
		super();
		initGUI();
	}
	
	private void initGUI() {
		
		try {
			setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
			getContentPane().setLayout(null);
			{
				lblFirstName = new JLabel();
				getContentPane().add(lblFirstName);
				lblFirstName.setText("First Name:");
				lblFirstName.setBounds(19, 17, 90, 15);
			}
			{
				lblLastName = new JLabel();
				getContentPane().add(lblLastName);
				lblLastName.setText("Last Name:");
				lblLastName.setBounds(21, 49, 88, 15);
			}
			{
				lblAddress = new JLabel();
				getContentPane().add(lblAddress);
				lblAddress.setText("Address:");
				lblAddress.setBounds(32, 77, 77, 15);
			}
			{
				lblProvince = new JLabel();
				getContentPane().add(lblProvince);
				lblProvince.setText("Province:");
				lblProvince.setBounds(32, 155, 77, 15);
			}
			{
				lblPostal = new JLabel();
				getContentPane().add(lblPostal);
				lblPostal.setText("Postal Code:");
				lblPostal.setBounds(12, 197, 104, 15);
			}
			{
				lblCity = new JLabel();
				getContentPane().add(lblCity);
				GridLayout lblCityLayout = new GridLayout(1, 1);
				lblCityLayout.setColumns(1);
				lblCityLayout.setHgap(5);
				lblCityLayout.setVgap(5);
				lblCity.setLayout(null);
				lblCity.setText("City:");
				lblCity.setBounds(50, 121, 59, 15);
			}
			{
				btnSave = new JButton();
				getContentPane().add(btnSave);
				btnSave.setText("Save");
				btnSave.setBounds(24, 248, 77, 24);
				btnSave.addMouseListener(new MouseAdapter() {
					public void mouseClicked(MouseEvent evt) {
						//TODO add your code for btnSave.mouseClicked
						StringBuffer sb = new StringBuffer();
						sb.append("Customer Data: \nFirst Name = "); 
						sb.append(txtFirstName.getText());
						sb.append("\nLast Name = "); 
						sb.append(txtLastName.getText());
						sb.append("\nAddress = "); 
						sb.append(txtAddress.getText());
						sb.append("\nCity = "); 
						sb.append(txtCity.getText());
						sb.append("\nProvince = "); 
						sb.append(txtProvince.getText());
						sb.append("\nPostal Code = "); 
						sb.append(txtPostal.getText());
						JOptionPane.showMessageDialog(inst, sb, "mutha fucka", JOptionPane.INFORMATION_MESSAGE);
						
					}
				});
			}
			{
				btnCancel = new JButton();
				getContentPane().add(btnCancel);
				btnCancel.setText("Cancel");
				btnCancel.setBounds(156, 249, 92, 22);
				btnCancel.addMouseListener(new MouseAdapter(){
					//need to override the mouseClicked method.
					public void mouseClicked(MouseEvent e)
					{
						if(JOptionPane.showConfirmDialog(inst, "Are You Sure?", "mutha fucka", JOptionPane.OK_CANCEL_OPTION) == JOptionPane.OK_OPTION)
						{
						txtFirstName.setText("");
						txtLastName.setText("");
						txtAddress.setText("");
						txtCity.setText("");
						txtProvince.setText("");
						txtPostal.setText("");
						}
					}
				});
				
			}
			{
				txtFirstName = new JTextField();
				getContentPane().add(txtFirstName);
				txtFirstName.setBounds(170, 14, 174, 22);
			}
			{
				txtLastName = new JTextField();
				getContentPane().add(txtLastName);
				txtLastName.setBounds(170, 46, 174, 22);
			}
			{
				txtAddress = new JTextField();
				getContentPane().add(txtAddress);
				txtAddress.setBounds(170, 74, 174, 22);
			}
			{
				txtCity = new JTextField();
				getContentPane().add(txtCity);
				txtCity.setBounds(170, 118, 174, 22);
			}
			{
				txtProvince = new JTextField();
				getContentPane().add(txtProvince);
				txtProvince.setBounds(170, 152, 174, 22);
			}
			{
				txtPostal = new JTextField();
				getContentPane().add(txtPostal);
				txtPostal.setBounds(170, 194, 174, 22);
			}
			pack();
			this.setSize(392, 356);
		} catch (Exception e) {
		    //add your error handling code here
			e.printStackTrace();
		}
	}

}
